<template>
	<view class="pay-success">
		<!-- 首页金刚区支付成功页面 -->
		<u-navbar leftIconSize="34rpx" autoBack :placeholder="true" bgColor="#ffffff">
			<view slot="center">
				<text class="c-000 pf-sc fw-600" style="font-size: 34rpx;">支付成功</text>
			</view>
		</u-navbar>
		<view
			class="authentication-container w-750 b-box  bg-fa po-re"
			:style="{ height: containerHeight }"
		>
			<view
				class="authentication-container w-750 b-box d-flex flex-c ali-i-c just-c  bg-fa po-re"
				:style="{ height: parseInt(containerHeight) / 2.2 + 'px' }"
			>
				<image
					src="../static/success_pic.png"
					style="width: 198rpx;height: 198rpx;margin: 88rpx 0 32rpx;"
				></image>
				<text class="pf-sc fw-500" style="font-size: 34rpx;color: #222222;margin-bottom: 12rpx;">
					支付成功
				</text>
				<text class="pf-sc fw-400" style="font-size: 26rpx;color: #666666;margin-bottom: 68rpx;">
					您可指定师傅为您服务，若不指定将由系统为您分配
				</text>
				<view class="b-box d-flex flex-r ali-i-c just-sw" style="width: 530rpx;">
					<u-button
						:throttleTime="700"
						plain
						@click="ReleaseInformation"
						:customStyle="{
							height: '74rpx',
							width: '240rpx',
							font: '400 28rpx PingFang SC',
							color: '#333333',
							borderWidth: '0rpx',
							margin: '0rpx',
							borderRadius: '44rpx',
							border: '1rpx solid #dcdcdc'
						}"
						shape="square"
						text="直接发布"
					></u-button>
					<u-button
						:throttleTime="700"
						plain
						@click="Assign"
						:customStyle="{
							height: '74rpx',
							width: '240rpx',
							font: '400 28rpx PingFang SC',
							color: '#26387C',
							borderWidth: '0rpx',
							margin: '0rpx',
							borderRadius: '44rpx',
							border: '2rpx solid #26387C'
						}"
						shape="square"
						text="指定师傅"
					></u-button>
				</view>
			</view>
		</view>
		<u-picker
			:show="pickerShow"
			cancelColor="#999999"
			confirmColor="#333333"
			@cancel="close"
			@close="close"
			@confirm="zdshifu"
			@change="change"
			title="指定师傅"
			:columns="columnData"
			:itemHeight="82"
			keyName="username"
		></u-picker>
	</view>
</template>

<script>
import { _containerHeight, _addUnit, _rpxTpx } from '@/utils/GetSys.js';
import { getcarlist, summitorder, workerorpublish } from '@/common/api.js';
import Ubutton from '../components/uview-ui/components/u-button/u-button';
import uNavbar from '../components/uview-ui/components/u-navbar/u-navbar';
import uPicker from '../components/uview-ui/components/u-picker/u-picker';
import uPickerColumn from '../components/uview-ui/components/u-picker-column/u-picker-column';
export default {
	components: {
		'u-button': Ubutton,
		'u-navbar': uNavbar,
		'u-picker': uPicker,
		'u-picker-column': uPickerColumn
	},
	data() {
		return {
			containerHeight: '',
			pickerShow: false, //选择器开关
			oid: '',
			columnData: []
		};
	},
	methods: {
		//获取师傅列表
		workerList() {
			let params = {
				token: uni.getStorageSync('usertoken'),
				type: 3,
				oid: this.oid,
				page: 1
			};
			workerorpublish(params).then(res => {
				console.log(res);
				this.columnData = [res.data.data];
				console.log(this.columnData);
			});
		},
		//指定师傅
		//获取师傅列表
		zdshifu(e) {
			console.log(e.indexs[0]);
			var idindex = e.indexs[0];
			let params = {
				token: uni.getStorageSync('usertoken'),
				type: 2,
				oid: this.oid,
				wid: this.columnData[0][idindex].id
			};
			workerorpublish(params).then(res => {
				if (res.data.code == 1) {
					uni.navigateTo({
						url: '/userModelA/userA/SubmitSuccess/SubmitSuccess'
					});
				}
			});
		},
		ReleaseInformation(type) {
			//直接发布
			let params = {
				token: uni.getStorageSync('usertoken'),
				type: 1,
				oid: this.oid,
				page: 1
			};
			workerorpublish(params).then(res => {
				if (res.data.code === 1) {
					uni.navigateTo({
						url: '/userModelA/userA/SubmitSuccess/SubmitSuccess'
					});
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					});
				}
			});
		},
		Assign() {
			//指定师傅
			this.pickerShow = true;
		},
		close() {
			this.pickerShow = false;
		},
		change() {},
		confirm() {
			// ToDo...
			this.close();
		}
	},
	onLoad(options) {
		console.log(options, '传来的订单');
		this.oid = options.oid;
		console.log(this.oid, '传来的订单的id');
		this.workerList();
		this.containerHeight = _containerHeight();
	}
};
</script>

<style lang="scss">
.pay-success {
	.u-toolbar {
		background-color: #f4f4f4 !important;
	}
	.u-toolbar__wrapper__cancel {
		font-size: 32rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}
	.u-toolbar__wrapper__confirm {
		font-size: 32rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}
	.u-toolbar__title {
		font-size: 32rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #666666;
	}
	.u-picker__view__column__item {
		background-color: #fff;
		line-height: 68rpx !important;
	}
}
</style>
